package com.ext.aic.apis;

import com.ext.aic.builder.ParamsBuilder;
import com.hjq.http.config.IRequestApi;

public class ApiDefine implements IRequestApi {

    private String relativePath;

    public ApiDefine(String relativePath, ParamsBuilder builder) {
        if (builder != null) {
            String queryParams = builder.build();
            if (relativePath.lastIndexOf("?") >= 0) {
                this.relativePath = relativePath + "&" + queryParams;
            } else {
                this.relativePath = relativePath + "?" + queryParams;
            }
        } else {
            this.relativePath = relativePath;
        }
    }

    public ApiDefine(String relativePath) {
        this(relativePath, null);
    }

    @Override
    public String getApi() {
        return relativePath;
    }
}
